package _4_StackAndQueue;

import java.util.ArrayDeque;
import java.util.Deque;
import java.util.LinkedList;
import java.util.Stack;

public class A09_CQueue {
    class CQueue {
        Stack<Integer> inStack;
        Stack<Integer> outStack;

        public CQueue() {
            inStack = new Stack<>();
            outStack = new Stack<>();
        }

        public void appendTail(int value) {
            inStack.push(value);
        }

        public int deleteHead() {
            //判断两个栈里面有没有元素了
            while(outStack.isEmpty()){
                while(inStack.isEmpty()){
                    return -1;
                }
            }
            //如果铀元素,则删除元素，先从outStack中找有没有元素,如果没有,就从inStack中放到outStack中
            while(!inStack.isEmpty()){
                outStack.push(inStack.pop());
            }
            return outStack.pop();
        }
    }
}
